﻿using System.Data;
using System.Windows.Forms;
using UI.ParentForm;
using Components;
using UI.Lib;
using System.Collections;
using UI.Lib.Factory;

namespace UI.BuyManagement
{
    public partial class FrmBuyQuery : BaseQuery
    {
        public FrmBuyQuery(string modulecode, string action) :
            base(modulecode, action)
        {
            InitializeComponent();
        }

        public override bool BeforePopWin(string name, ref string where, ref string[] others)
        {
            if ("productcode" == name)
            {
                where = string.Format("status ='1' {0}", Context.GetAppKeyWhere("muser", true));
            }
            else if ("sellercode" == name)
            {
                where = string.Format(" status ='1' {0} ", Context.GetAppKeyWhere("usercode", true));
            }
            else if ("providercode" == name)
            {
                where = string.Format(" status <> '4' {0} ", Context.GetAppKeyWhere("usercode", true));
            }

            return true;
        }

        protected override void DoSearch()
        {
            //控制明细中列显示
            var where = new Hashtable();
            where["pid"] = Validation.ToString(this.tbSummary.GetValue("pid")); //控件ID
            where["startdate"] = Validation.ToDate(this.tbSummary.GetValue("startdate"), Global.MinDate); //控件ID
            where["endate"] = Validation.ToDate(this.tbSummary.GetValue("endate"), Global.MaxDate); //结束日期
            where["supplier"] = Validation.ToString(this.tbSummary.GetValue("plistid"));

            DataTable dt = CommonHelper.Entity.ExecFun("getbuydatadetail", where);

            BinderGrid(dt);
        }
    }
}
